import Vue from 'vue'
import App from './App.vue'
import router from './router'
import axios from 'axios'
import vueAxios from 'vue-axios'
import store from './store'
import VueLazyLoad from 'vue-lazyload'
import VueCookie from 'vue-cookie'
Vue.config.productionTip = false
Vue.use(vueAxios, axios)
Vue.use(VueCookie)



Vue.use(VueLazyLoad, {
  loading: '@/assets/imgs/loading-svg/loading-bars.svg'
})

import Vant, { Lazyload } from 'vant';
import 'vant/lib/index.css';
Vue.use(Vant);
Vue.use(Lazyload);

// 根据前端的跨域方式做调整
// 当前接口的域名和前端的域名是一样的
axios.defaults.baseURL = 'https://mock.presstime.cn/mock/632471b7b98faa00824e3915/mimall';
axios.defaults.timeout = '8000';

// 根据不同的环境变量去匹配地址

// 接口错误拦截
axios.interceptors.response.use(function (response) {
  let res = response.data;
  if (res.status == 0) {
    return res.data;
  } else if (res.status == 10) {
    window.location.href = "/#/login"

  } else {
    alert(res.msg)
    return Promise.reject(res)
  }
})
new Vue({
  store,
  router,
  render: h => h(App),
}).$mount('#app')
